# -*- coding: utf-8 -*-
__author__ = 'hftec'
import random
from lcopa import load_uphi_data,calculate_codev,lcopa_usb

class LcopaScan:
    def __init__(self,usb_id,uphi_name,left,right,step):
        self.uphi = load_uphi_data.u_phi("./u-phi/DF2015-FA02.txt")
        self.left = left
        self.right = right
        self.step = step
        self.curr_angle = left
        self.lcopausb = lcopa_usb.LcopaUsb()
        self.lcopausb.open(usb_id)
        self.lcoap = calculate_codev.lcopa_vol(self.uphi)

        # btyes=lcoap.calculate_voltage((0.003))
    def auto_scan(self):
        pass
    def next_scan(self):
        if self.curr_angle >= self.right:
            self.curr_angle = self.left
        else:
            self.curr_angle += self.step
            if self.curr_angle > self.right:
                self.curr_angle = self.right
        self.lcopausb.send_byte(self.curr_angle)
